package org.mall.modules.product.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mall.common.api.vo.CommonResult;
import org.mall.common.system.util.JwtUtil;
import org.mall.modules.pojo.product.ProductCollectionVO;
import org.mall.modules.product.service.ProductSpuCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.mall.common.api.vo.CommonResult.success;


@RestController
@RequestMapping("/users/spu")
@Api("商品收藏")
public class UsersProductSpuCollectionController {

    @Autowired
    private ProductSpuCollectionService productSpuCollectionService;

    @PostMapping("/collection")
    @ApiOperation("商品收藏")
    public CommonResult<Boolean> productSpuCollection(@RequestBody ProductCollectionVO vo) {
        return success(productSpuCollectionService.productSpuCollection(vo.getSpuId(), vo.getHasCollectionType(), JwtUtil.getUserIdByToken()));
    }
}
